﻿<%@ WebHandler Language="C#" Class="ZSWorkcenterDealFaultBill" %>

using System;
using System.Web;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using System.Web.SessionState;
using System.IO;
using ReportBusiness;

public class ZSWorkcenterDealFaultBill : IHttpHandler
{
    public bool IsReusable { get { return false; } }
    private static ZSDealFaultBillBusiness pdb = new ZSDealFaultBillBusiness();
    private uMESReportOracleDAL dal = new uMESReportOracleDAL();
    public void ProcessRequest(HttpContext context)
    {
        //本月返件数据统计（柱状图）
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetZSThisMonthDealFaultBillCount")
        {
            //计算返件总数
            string sql = @"
SELECT COUNT(1) total
FROM
(
    SELECT db.dealfaultbillname,dbt.recvFactoryReturnTime,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NULL AND db.transferstatus < 6
                      
    UNION ALL 
                      
    SELECT db.dealfaultbillname,dbt.recvFactoryReturnTime,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NOT NULL
        AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1
) t 
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" WHERE t.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            DataTable dtTotal = dal.GetDataTable(sql);

            //计算已返出数量
            sql = @"
SELECT COUNT(1) fanChuQty
FROM
(
    SELECT db.dealfaultbillname,dbt.recvFactoryReturnTime,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NULL AND db.transferstatus < 6 AND dbt.FromTime IS NOT NULL
                      
    UNION ALL 
                      
    SELECT db.dealfaultbillname,dbt.recvFactoryReturnTime,workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NOT NULL
        AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1
        AND dbt.FromTime IS NOT NULL
) t 
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" WHERE t.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            DataTable dtFanChuQty = dal.GetDataTable(sql);

            //计算已完成数
            sql = @"
SELECT COUNT(1) finishedQty
FROM
(
    SELECT db.dealfaultbillname,dbt.recvFactoryReturnTime,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NULL AND db.transferstatus < 6 AND dbt.finishtime IS NOT NULL
                      
    UNION ALL 
                      
    SELECT db.dealfaultbillname,dbt.recvFactoryReturnTime,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NOT NULL
        AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1
        AND dbt.finishtime IS NOT NULL
) t 
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" WHERE t.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }
            DataTable dtFinishedQty = dal.GetDataTable(sql);

            //计算预超期数
            sql = @"
SELECT COUNT(1) yuChaoQiQty
FROM DealFaultBill db
LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
WHERE dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NULL
      AND TRUNC(to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(SYSDATE,'yyyy/mm/dd'),'yyyy/mm/dd')) = 0
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            DataTable dtYuChaoQiQty = dal.GetDataTable(sql);

            //计算超期数
            sql = @"
SELECT COUNT(1) chaoQiQty
FROM
(
    SELECT db.dealfaultbillid,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NOT NULL
        AND TRUNC(to_date(to_char(dbt.finishtime,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd')) > 0
                      
    UNION ALL
                      
    SELECT db.dealfaultbillid,w.workcentername
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NULL
        AND TRUNC(to_date(to_char(SYSDATE,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd')) > 0
) t
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" WHERE t.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }
            DataTable dtChaoQiQty = dal.GetDataTable(sql);

            DataTable dtResult = new DataTable();
            dtResult.Columns.Add("total");//总数
            dtResult.Columns.Add("fanChuQty");//已转出
            dtResult.Columns.Add("finishedQty");//已完成
            dtResult.Columns.Add("yuChaoQiQty");//预超期
            dtResult.Columns.Add("chaoQiQty");//超期

            DataRow dr = dtResult.NewRow();
            dr["total"] = dtTotal.Rows[0]["total"];
            dr["fanChuQty"] = dtFanChuQty.Rows[0]["fanChuQty"];
            dr["finishedQty"] = dtFinishedQty.Rows[0]["finishedQty"];
            dr["yuChaoQiQty"] = dtYuChaoQiQty.Rows[0]["yuChaoQiQty"];
            dr["chaoQiQty"] = dtChaoQiQty.Rows[0]["chaoQiQty"];

            dtResult.Rows.Add(dr);

            var json = JsonConvert.SerializeObject(dtResult);
            context.Response.ContentType = "text/json";
            context.Response.Write(json.ToString());
            context.Response.End();
        }

        //本月各机型返件情况（饼图）
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetThisMonthDealFaultProductFamilyInfo")
        {
            string sql = @"
SELECT db.enginefamily,COUNT(1) qty
FROM DealFaultBill db
LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
WHERE dbt.recvFactoryReturnTime IS NOT NULL
      AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"
GROUP BY db.enginefamily
";

            DataTable dt = dal.GetDataTable(sql);

            var json = JsonConvert.SerializeObject(dt);
            context.Response.ContentType = "text/json";
            context.Response.Write(json.ToString());
            context.Response.End();
        }

        //本月各单位完成情况--柱状图
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetZSThisMonthDealFaultBillFactoryCount")
        {
            //计算返件总数
            string sql = @"
SELECT t.factoryname,COUNT(1) total
FROM
(
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NULL AND db.transferstatus < 6 
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"        
    UNION ALL 
                      
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NOT NULL
        AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1 
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"
) t
GROUP BY t.factoryname 
";
            DataTable dtTotal = dal.GetDataTable(sql);

            //计算已返出数量
            sql = @"
SELECT t.factoryname,COUNT(1) fanChuQty
FROM
(
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid 
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NULL AND db.transferstatus < 6 AND dbt.FromTime IS NOT NULL 
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"                      
    UNION ALL 
                      
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NOT NULL
        AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1
        AND dbt.FromTime IS NOT NULL ";

            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"
) t 
GROUP BY t.factoryname
";

            DataTable dtFanChuQty = dal.GetDataTable(sql);

            //计算已完成数
            sql = @"
SELECT t.factoryname,COUNT(1) finishedQty
FROM
(
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NULL AND db.transferstatus < 6 AND dbt.finishtime IS NOT NULL
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"                    
    UNION ALL 
                      
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.recvFactoryReturnTime IS NOT NULL
        AND dbt.recvFactoryReturnTime >= trunc(sysdate,'month') AND dbt.recvFactoryReturnTime <= trunc(last_day(sysdate)) + 1
        AND dbt.finishtime IS NOT NULL
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"
) t 
GROUP BY t.factoryname
";
            DataTable dtFinishedQty = dal.GetDataTable(sql);

            //计算预超期数
            sql = @"
SELECT f.factoryname,COUNT(1) yuChaoQiQty
FROM DealFaultBill db
LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
WHERE dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NULL
        AND TRUNC(to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(SYSDATE,'yyyy/mm/dd'),'yyyy/mm/dd')) = 0
GROUP BY f.factoryname
";

            DataTable dtYuChaoQiQty = dal.GetDataTable(sql);

            //计算超期数
            sql = @"
SELECT t.factoryname,COUNT(1) chaoQiQty
FROM
(
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NOT NULL
        AND TRUNC(to_date(to_char(dbt.finishtime,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd')) > 0
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"
                      
    UNION ALL
                      
    SELECT f.factoryname
    FROM DealFaultBill db
    LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
    LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
    LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
    LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
    WHERE dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NULL
        AND TRUNC(to_date(to_char(SYSDATE,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd')) > 0
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            sql += @"
) t
GROUP BY t.factoryname
";
            DataTable dtChaoQiQty = dal.GetDataTable(sql);

            sql = @"
SELECT DISTINCT f.factoryname
FROM DealFaultBill db
LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
WHERE f.factoryname IS NOT NULL
";
            DataTable dtResult = dal.GetDataTable(sql);
            dtResult.Columns.Add("total");//总数
            dtResult.Columns.Add("fanChuQty");//已转出
            dtResult.Columns.Add("finishedQty");//已完成
            dtResult.Columns.Add("yuChaoQiQty");//预超期
            dtResult.Columns.Add("chaoQiQty");//超期

            foreach (DataRow dr in dtResult.Rows)
            {
                string filter = string.Format("factoryname = '{0}'", dr["factoryname"].ToString());
                dr["total"] = dtTotal.Select(filter).Length > 0 ? dtTotal.Select(filter)[0]["total"] : 0;
                dr["fanChuQty"] = dtFanChuQty.Select(filter).Length > 0 ? dtFanChuQty.Select(filter)[0]["fanChuQty"] : 0;
                dr["finishedQty"] = dtFinishedQty.Select(filter).Length > 0 ? dtFinishedQty.Select(filter)[0]["finishedQty"] : 0;
                dr["yuChaoQiQty"] = dtYuChaoQiQty.Select(filter).Length > 0 ? dtYuChaoQiQty.Select(filter)[0]["yuChaoQiQty"] : 0;
                dr["chaoQiQty"] = dtChaoQiQty.Select(filter).Length > 0 ? dtChaoQiQty.Select(filter)[0]["chaoQiQty"] : 0;

                if (dr["factoryname"].ToString().Contains("结构件"))
                {
                    dr["factoryname"] = "结构件";
                }
                else if (dr["factoryname"].ToString().Contains("燃烧"))
                {
                    dr["factoryname"] = "燃烧";
                }
                else if (dr["factoryname"].ToString().Contains("盘轴"))
                {
                    dr["factoryname"] = "盘轴";
                }
                else if (dr["factoryname"].ToString().Contains("机匣"))
                {
                    dr["factoryname"] = "机匣";
                }
                else if (dr["factoryname"].ToString().Contains("热表"))
                {
                    dr["factoryname"] = "热表";
                }
                else if (dr["factoryname"].ToString().Contains("发动机"))
                {
                    dr["factoryname"] = "总装";
                }
            }

            var json = JsonConvert.SerializeObject(dtResult);
            context.Response.ContentType = "text/json";
            context.Response.Write(json.ToString());
            context.Response.End();
        }

        //返件信息明细（表格）
        if (context.Request.QueryString["type"] != null && context.Request.QueryString["type"] == "GetDealFaultBillDetail")
        {
            Dictionary<string, object> para = new Dictionary<string, object>();

            para["currentPage"] = context.Request.Form["page"].ToString();
            para["pageSize"] = context.Request.Form["rows"].ToString();

            int pageCount = 0;
            int rowCount = 0;

            string sql = @"
SELECT db.dealfaultbillname,db.engineno,db.productname,db.productbatchno,f.factoryname,
        CASE WHEN db.transferstatus = 2 AND dbt.revrejectreason IS NOT NULL THEN '接收退回'
            WHEN db.transferstatus = 5 AND dbt.revreturnrejectreason IS NOT NULL THEN '返回退回'
            WHEN db.transferstatus = 2 THEN '待返出'
            WHEN db.transferstatus = 3 THEN '待接收'
            WHEN db.transferstatus = 4 THEN '待完成'
            WHEN db.transferstatus = 5 THEN '待返回' 
        END status,
        dbt.FromTime,dbt.RequireFinishTime,dbt.RecvFactoryTime,dbt.estimatedcompletedate,dbt.finishtime,
        CASE WHEN dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NOT NULL
                    THEN TRUNC(to_date(to_char(dbt.finishtime,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd'))
            WHEN dbt.estimatedcompletedate IS NOT NULL AND dbt.finishtime IS NULL
                    THEN TRUNC(to_date(to_char(SYSDATE,'yyyy/mm/dd'),'yyyy/mm/dd') - to_date(to_char(dbt.estimatedcompletedate,'yyyy/mm/dd'),'yyyy/mm/dd'))
        ELSE 0 END delayDays,db.faultdesc
FROM DealFaultBill db
LEFT JOIN dealfaultbilltransfer dbt ON dbt.dealfaultbillid = db.dealfaultbillid
LEFT JOIN factory f ON f.factoryid = db.returnfactoryid
LEFT JOIN Sessionvalues sv ON sv.employeeid = db.createemployeeid
LEFT JOIN Workcenter w ON w.workcenterid = sv.workcenterid
WHERE db.transferstatus IN ('2','3','4','5')
";
            if (context.Request.Form["workcentername"] != null)
            {
                sql += string.Format(" AND w.workcentername like '%{0}%' ", context.Request.Form["workcentername"].ToString());
            }

            uMESPagingDataDTO retR = dal.GetPagingDataIns(sql, int.Parse(para["currentPage"].ToString()), int.Parse(para["pageSize"].ToString()));

            pageCount = Convert.ToInt32(retR.PageCount);
            rowCount = Convert.ToInt32(retR.RowCount);

            var json = JsonConvert.SerializeObject(retR.DBTable);
            context.Response.ContentType = "text/json";
            json = "{\"data\":" + json.ToString()
                    + ",\"count\":" + rowCount
                    + ",\"code\":" + "0"
                    + ",\"msg\":" + "0"
                    + "}";
            context.Response.Write(json.ToString());
            context.Response.End();
        }
    }
}